//
//  XLKitchenHeaderView.m
//  The_DownKitchen
//
//  Created by Apple on 16/7/20.
//  Copyright © 2016年 The_X. All rights reserved.
//

#import "XLKitchenHeaderView.h"
#import <Masonry.h>

@implementation XLKitchenHeaderView

- (instancetype)init {
    
    if (self = [super init]) {
        
        //创建顶部两个菜谱按钮
        UIButton *popularRecipeBtn = [[UIButton alloc] init];
        UIButton *friendRecipeBtn = [[UIButton alloc] init];
        
        //为菜谱按钮添加点击事件
//        [popularRecipeBtn addTarget:self action:@selector(<#selector#>) forControlEvents:UIControlEventTouchUpOutside];
//        [friendRecipeBtn addTarget:self action:@selector(<#selector#>) forControlEvents:UIControlEventTouchUpOutside];

        //加入父视图
        [self addSubview:popularRecipeBtn];
        [self addSubview:friendRecipeBtn];
        
        //设置约束
        [popularRecipeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.left.equalTo(self).offset(0);
            make.width.height.equalTo(friendRecipeBtn);
        }];
        
        [friendRecipeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.top.right.equalTo(self).offset(0);
            make.height.mas_equalTo(110);
            make.width.mas_equalTo(kXLScreenWidth * 0.5 - 0.5);
        }];
        
        popularRecipeBtn.backgroundColor = [UIColor redColor];
        [friendRecipeBtn setBackgroundImage:[UIImage imageNamed:@"feedsNoFriends"] forState:UIControlStateNormal];
        
        //创建每个菜谱按钮中的文字框和图片框
        UILabel *popularRecipeLbl = [[UILabel alloc] init];
        UILabel *friendRecipeLbl = [[UILabel alloc] init];
        UIImageView *friendRecipeImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"feedsNoFriendsIcon"]];
        
        //设置文本框属性
        popularRecipeLbl.text = @"本周流行菜谱";
        popularRecipeLbl.textAlignment = NSTextAlignmentCenter;
        popularRecipeLbl.textColor = [UIColor whiteColor];
        popularRecipeLbl.font = [UIFont systemFontOfSize:15];
        
        friendRecipeLbl.text = @"查看好友并关注";
        friendRecipeLbl.textAlignment = NSTextAlignmentCenter;
        friendRecipeLbl.textColor = [UIColor whiteColor];
        friendRecipeLbl.font = [UIFont systemFontOfSize:15];

        
        //加入父视图
        [self addSubview:popularRecipeLbl];
        [self addSubview:friendRecipeLbl];
        [self addSubview:friendRecipeImage];
        
        //设置约束
        [popularRecipeLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(popularRecipeBtn).offset(0);
            make.bottom.equalTo(popularRecipeBtn).offset(-10);
            make.height.mas_equalTo(20);
            make.width.mas_equalTo(popularRecipeBtn);
        }];
        
        [friendRecipeLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.equalTo(friendRecipeBtn).offset(0);
            make.bottom.equalTo(friendRecipeBtn).offset(-10);
            make.height.mas_equalTo(20);
            make.width.mas_equalTo(friendRecipeBtn);
        }];
        
        [friendRecipeImage mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.width.height.mas_equalTo(40);
            make.bottom.equalTo(friendRecipeLbl).offset(-30);
            make.centerX.equalTo(friendRecipeBtn);
        }];
        
        
        
        
        
    }
    return self;
}

@end
